package com.iot.ht.controller.htpage;

import com.iot.core.annotation.Auth;
import com.iot.core.annotation.Log;
import com.iot.core.data.BasePageDtQto;
import com.iot.core.data.BaseQto;
import com.iot.core.enums.AuthType;
import com.iot.ht.controller.htpage.data.HtPageAuthDto;
import com.iot.ht.controller.htpage.data.HtPageDto;
import com.iot.ht.controller.htpage.service.IHtPageService;
import com.mybatisflex.core.paginate.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/htpage")
@Tag(name = "功能菜单", description = "")
public class HtPageController {
    @Autowired
    IHtPageService ihtPageService;

    @Auth(authType = AuthType.Login)
    @Log(logNeed = false,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/page")
    @Operation(summary = "功能菜单分页", description = "")
    public Page<HtPageDto> page(@RequestBody BasePageDtQto mm){
        return ihtPageService.page(mm);
    }



    @Auth(authType = AuthType.Login)
    @Log(logNeed = false,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/detail")
    @Operation(summary = "功能菜单详情", description = "")
    public  HtPageDto detail(@RequestBody BaseQto mm){
        return ihtPageService.detail(mm);
    }




    @Auth(authType = AuthType.Login)
    @Log(logNeed = false,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/insertinit")
    @Operation(summary = "插入功能菜单初始化", description = "")
    public HtPageDto insertInit( )   {
         return  ihtPageService.insertInit();
    }

    @Auth(authType = AuthType.Login)
    @Log(logNeed = false,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/insertauthinit")
    @Operation(summary = "插入页面权限初始化", description = "")
    public HtPageAuthDto insertAuthInit( )   {
        return  ihtPageService.insertAuthInit();
    }


    @Auth(authType = AuthType.Auth)
    @Log(logNeed = true,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/insert")
    @Operation(summary = "新增功能菜单", description = "")
    public  int insert(@RequestBody HtPageDto mm){
        return ihtPageService.insert(mm);
    }


    @Auth(authType = AuthType.Auth)
    @Log(logNeed = true,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/update")
    @Operation(summary = "修改功能菜单", description = "")
    public  int update(@RequestBody HtPageDto mm){
        return ihtPageService.update(mm);
    }


    @Auth(authType = AuthType.Auth)
    @Log(logNeed = true,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/delete")
    @Operation(summary = "删除功能菜单", description = "")
    public  int delete(@RequestBody BaseQto mm){
        return ihtPageService.delete(mm);
    }



    @Auth(authType = AuthType.Login)
    @Log(logNeed = false,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/insertinitforctl")
    @Operation(summary = "根据ctlid新增功能菜单初始化", description = "")
    public HtPageDto  insertinitforctl(@RequestBody BaseQto mm){
        return ihtPageService.insertInitForCtl(mm.getId() );
    }




}
